<template>
  <!-- This footer should be hidden by default and shown when there are todos -->
  <footer class="footer">
    <!-- This should be `0 items left` by default -->
    <span class="todo-count"
      ><strong>{{ num }}</strong> 条未完成</span
    >
    <!-- Remove this if you don't implement routing -->
    <ul class="filters" @click="toggleFn">
      <li>
        <a href="#/" :class="{ selected: type == 'all' }" @click="type = 'all'"
          >全部</a
        >
      </li>
      <li>
        <a
          href="#/active"
          :class="{ selected: type == 'no' }"
          @click="type = 'no'"
          >未完成</a
        >
      </li>
      <li>
        <a
          href="#/completed"
          :class="{ selected: type == 'yes' }"
          @click="type = 'yes'"
          >已完成</a
        >
      </li>
    </ul>
    <!-- Hidden if no completed items are left ↓ -->
    <button class="clear-completed" @click="clearFn" v-if="isShow">清除已完成</button>
  </footer>
</template>

<script>
export default {
    methods:{
toggleFn(){
    this.$emit("toggle-todo",this.type)
},
clearFn(){
    this.$emit("clear-todo")
}
    },
  data() {
    return {
      type: "all", //no yes
    };
  },
  props: ["arr"],
  computed: {
    num() {
      return this.arr.filter((item) => item.isDone == false).length;
    },
    isShow(){
        return this.arr.some((item) =>item.isDone==true)
    }
  },
};
</script>

<style>
</style>